//
//  UILabel+Extension.swift
//  weibo27
//
//  Created by mac on 16/4/17.
//  Copyright © 2016年 it.cast. All rights reserved.
//

import UIKit

extension UILabel{
    //screenInset默认为零中间对其，一旦设置值，就是左对齐，并设置显示的宽度
    ///遍历构造函数，就是外界通过参数传进来快速的创建对象
    convenience init(title: String,
        fontSize :CGFloat = 14,
        color: UIColor = UIColor.darkGrayColor(),
        screenInset:CGFloat = 0
        ){
        
        self.init()
        
        text = title;
        
        textColor = color
        
        numberOfLines = 0
        
        font = UIFont.systemFontOfSize(fontSize)
        
            if screenInset==0{
                 textAlignment = .Center
            }else{
                textAlignment = .Left
                preferredMaxLayoutWidth = kScreenW - 2*screenInset
            }
            
           sizeToFit()
    }
}
